<%@page import="com.hamizhong.iflowers.utils.MyConstants"%>
<%@page import="com.hamizhong.iflowers.utils.MyColumnIndicator"%>
<%@page import="com.hamizhong.iflowers.web.vo.UserVO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@include file="../../common/common_admin.jsp" %>
<title>用户详情</title>
</head>

<%
	UserVO userVO = (UserVO)request.getAttribute("userVO");
%>

<body>
	<div class="displayPageHeader">当前位置：用户管理 >> 用户管理>> 用户详情</div>
	<div class="pageDiv">
		<div class="pageHeadDiv"><font>用户详情</font></div>
		<div class="infoDiv">
			<div id="itemListDiv" class="itemListDiv">
				<table border="1px" width="100%">
					<tr>
						<td>用户ID</td>
						<td><%=userVO.getUserId() %></td>
					</tr>
					<tr>
						<td>用户名称</td>
						<td><input type="text" id="userName" name="userName" value="<%=userVO.getUserName() %>"></td>
					</tr>
					<tr>
						<td>Email</td>
						<td><input type="text" id="userEmail" name="userEmail" value="<%=userVO.getUserEmail() %>"></td>
					</tr>
					<tr>
						<td>联系方式</td>
						<td><input type="text" id="userPhone" name="userPhone" value="<%=userVO.getUserPhone() %>"></td>
					</tr>
					<tr>
						<td>注册时间</td>
						<td><%=userVO.getCreateDateStr() %></td>
					</tr>
				</table>
			</div>
		</div>
	</div>
	<div class="pageDiv">
		<div class="pageHeadDiv"><font>操作栏</font></div>
		<div class="infoDiv">
			<input style="margin: 10px 0;" type="button" onclick="closeWindow();" value="关闭窗口">
			<input style="margin: 10px 0;" type="button" onclick="resetUserPassword('<%=userVO.getUserId() %>','<%=userVO.getUserName() %>');" value="重置密码">
			<input style="margin: 10px 0;" type="button" onclick="updateUser('<%=userVO.getUserId() %>');" value="提交更新">
		</div>
	</div>
	<div class="margin_50"></div>
</body>

<script type="text/javascript">
	//父窗口对象
	var parentWindow = window.dialogArguments;
	
	function closeWindow() {
		window.close();
	}
	
	function updateUser(userId) {
		var userName = $('#userName').val();
		var userEmail = $('#userEmail').val();
		var userPhone = $('#userPhone').val();
		//alert(userId+"|"+userName+"|"+userEmail+"|"+userPhone);
		$.ajax({
			url: '<%=request.getContextPath() %>/admin/ajaxUpdateUser.action',
			data: {
				"userId": userId,
				"userName": userName,
				"userEmail": userEmail,
				"userPhone": userPhone
			},
			type: 'post',
			async: false,
			dataType: 'json',
			success: function(res) {
				var rs = res.result;
				if(rs != 0) {
					alert(res.msg);
					//closeWindow();
				}else {
					alert("操作成功！");
					closeWindow();
					parentWindow.initUserListByCondition(1);
				}
			}
		});
	}
	
	function resetUserPassword(userId, userName) {
		if(confirm("您确定要重置用户["+userName+"]的密码吗？")) {
			$.ajax({
				url: '<%=request.getContextPath() %>/admin/ajaxResetUserPassword.action',
				data: {
					"userId": userId
				},
				type: 'post',
				async: false,
				dataType: 'json',
				success: function(res) {
					var rs = res.result;
					if(rs != 0) {
						alert(res.msg);
						//closeWindow();
					}else {
						alert("操作成功！,该用户当前的密码为：[<%=MyConstants.IFLOWERS_RESET_USER_PASSWORD_VALUE %>]");
						closeWindow();
						parentWindow.initUserListByCondition(1);
					}
				}
			});
		}
	}
	
</script>

</html>